package de.slothsoft.wasbinich.core.database;

public enum DatabaseExceptionCode {
    INVALID_DATA, INVALID_LOGIN, INCOMPLETE_DATA, UNKNOWN, CANCELLED_BY_USER, ELEMENT_NOT_FOUND, INTERNAL_ERROR,
    // Slothsoft OAuth2
    INVALID_CLIENT, COULD_NOT_ENCODE, IO_ERROR, PARSE_ERROR, INVALID_GRANT;

    public static DatabaseExceptionCode fromValue(String codeName) {
	if (codeName == null)
	    return UNKNOWN;
	String codeNameCleanedUp = codeName.toUpperCase();
	for (DatabaseExceptionCode code : values())
	    if (code.name().equals(codeNameCleanedUp))
		return code;
	return UNKNOWN;
    }

    public String getMessage() {
	return Messages.getString(this);
    }
}
